package com.ruoyi.generator.service;

import com.ruoyi.generator.entity.*;
import com.ruoyi.generator.entity.dto.EditInvoice;
import com.ruoyi.generator.mapper.InvoiceFormMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 业务字段 服务层实现
 * 
 * @author ruoyi
 */
@Service
public class InvoiceServiceImpl implements InvoiceService
{

	@Autowired
	private InvoiceFormMapper invoiceFormMapper;

	@Autowired
	private com.ruoyi.generator.service.ContractService ContractService;
	@Override
	public List<InvoiceForm> selectInvoiceList(InvoiceSearchCriteria c) {
		return invoiceFormMapper.selectInvoiceList(c);
	}

	@Override
	public String queryAvailableAmountByInvoiceId(String invoiceId) {
		return invoiceFormMapper.queryAvailableAmountByInvoiceId(invoiceId);
	}

	@Override
	public int editInvoiceAmount(EditInvoice editInvoice) {


		StReturnValue returnValue = new StReturnValue();
		returnValue.setContractCode(editInvoice.getContractCode());
		returnValue.setInvoiceId(editInvoice.getInvoiceId());
		returnValue.setPayment(editInvoice.getInvoiceAmount());
		returnValue.setHasInvoice(editInvoice.getHasInvoice());
		returnValue.setFormType("edit");
		returnValue.setEditInvoice(editInvoice);
		int addReturnValue  = ContractService.addReturnValue(returnValue);
		return  addReturnValue;

	}
}
